package com.rome.hotel.data.service.impl;

import java.util.List;

import com.rome.hotel.data.utils.RegexUtils;
import io.jsonwebtoken.lang.Assert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.rome.hotel.data.mapper.HotelCarouselMapper;
import com.rome.hotel.data.domain.HotelCarousel;
import com.rome.hotel.data.service.IHotelCarouselService;

/**
 * 轮播Service业务层处理
 * 
 * @author rome
 * @date 2024-02-01
 */
@Service
public class HotelCarouselServiceImpl implements IHotelCarouselService 
{
    @Autowired
    private HotelCarouselMapper hotelCarouselMapper;

    /**
     * 查询轮播
     * 
     * @param carouselId 轮播主键
     * @return 轮播
     */
    @Override
    public HotelCarousel selectHotelCarouselByCarouselId(Long carouselId)
    {
        return hotelCarouselMapper.selectHotelCarouselByCarouselId(carouselId);
    }

    /**
     * 查询轮播列表
     * 
     * @param hotelCarousel 轮播
     * @return 轮播
     */
    @Override
    public List<HotelCarousel> selectHotelCarouselList(HotelCarousel hotelCarousel)
    {
        return hotelCarouselMapper.selectHotelCarouselList(hotelCarousel);
    }

    /**
     * 新增轮播
     * 
     * @param hotelCarousel 轮播
     * @return 结果
     */
    @Override
    public int insertHotelCarousel(HotelCarousel hotelCarousel)
    {
        Assert.notNull(hotelCarousel,"参数异常");
        Assert.notNull(hotelCarousel.getTitle(),"标题不能为空");
        Assert.state(RegexUtils.testStringNoThreeBai(hotelCarousel.getTitle()),"标题字数过多");
       if(hotelCarousel.getDescription()!=null){
           Assert.state(RegexUtils.testStringNoThreeBai(hotelCarousel.getDescription()),"描述字数过多");
       }
        return hotelCarouselMapper.insertHotelCarousel(hotelCarousel);
    }

    /**
     * 修改轮播
     * 
     * @param hotelCarousel 轮播
     * @return 结果
     */
    @Override
    public int updateHotelCarousel(HotelCarousel hotelCarousel)
    {
        Assert.notNull(hotelCarousel,"参数异常");
        Assert.notNull(hotelCarousel.getTitle(),"标题不能为空");
        Assert.state(RegexUtils.testStringNoThreeBai(hotelCarousel.getTitle())&&RegexUtils.testStringNoThreeBai(hotelCarousel.getDescription()),"标题或者描述字数过多");
        return hotelCarouselMapper.updateHotelCarousel(hotelCarousel);
    }

    /**
     * 批量删除轮播
     * 
     * @param carouselIds 需要删除的轮播主键
     * @return 结果
     */
    @Override
    public int deleteHotelCarouselByCarouselIds(Long[] carouselIds)
    {
        return hotelCarouselMapper.deleteHotelCarouselByCarouselIds(carouselIds);
    }

    /**
     * 删除轮播信息
     * 
     * @param carouselId 轮播主键
     * @return 结果
     */
    @Override
    public int deleteHotelCarouselByCarouselId(Long carouselId)
    {
        return hotelCarouselMapper.deleteHotelCarouselByCarouselId(carouselId);
    }
}
